package cool.mtc.minghe.service.manager.websocket.impl;

import cool.mtc.minghe.data.model.websocket.dto.WebSocketOnlineUserDTO;
import cool.mtc.minghe.service.manager.BaseManagerImpl;
import cool.mtc.minghe.service.manager.websocket.WebSocketManager;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 明河
 */
@Service
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class WebSocketManagerImpl extends BaseManagerImpl implements WebSocketManager {

    @Override
    @Cacheable(value = "ws:online", key = "'all'")
    public List<WebSocketOnlineUserDTO> listOnlineUser() {
        return new ArrayList<>();
    }

    @Override
    @CachePut(value = "ws:online", key = "'all'", unless = "null == #result")
    public List<WebSocketOnlineUserDTO> updateOnlineUser(List<WebSocketOnlineUserDTO> onlineUserList) {
        return onlineUserList;
    }
}
